<template>
  <div class="width-style">
    <LevelOnePageTop moduleName="人体使用手册" :catagoryList="catagoryList"/>
    <el-row :gutter="20">
      <el-col :span="18">
        <div class="grid-content">
          <InnerModuleLong innerModuleName="身体常识" :list="commonList"  :picSrc="require('@/assets/images/bodyUseCommon.png')" routeName="/bodyguide/commonsense"/>
          <!-- <InnerModule innerModuleName="身体常识" moduleName="人体使用手册" :list="commonList"  :picSrc="require('@/assets/images/bodyUseCommon.png')" routeName="/bodyguide/commonsense"/> -->
          <InnerModuleLong innerModuleName="生活习惯" :list="habitList"  :picSrc="require('@/assets/images/bodyUseHabit.jpg')" routeName="/bodyguide/habit"/>
          <InnerModuleLong innerModuleName="活动指南" :list="activityList" :picSrc="require('@/assets/images/bodyUseActivity.jpg')" routeName="/bodyguide/guide"/>
        </div>
      </el-col>
      <el-col :span="6">
        <div class="grid-content">
          <ModuleAdviser :doctorList="doctorList"/>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import LevelOnePageTop from '@/components/levelOnePageTop'
import {renderTime} from '@/utils/tools.js'
export default {
  name: "BodyGuide",
  layout: "homeLayout",
  components: { LevelOnePageTop },
  async asyncData({app}) {
    //获取当前类下的最热文章
    let res = await app.api.reqGeneralAllByCatalogue(5);
    if (res.code === 200) {
      for (let item of res.rows) {
        item.publishTime = renderTime(item.publishTime);
      }
    }
    //获取医生等列表
    let doctorRes=await app.api.reqAllDoctor();
    if(doctorRes.code===200){
      for(let doctor of doctorRes.rows){
        doctor.doctorAvatar=app.api.BASEURL+doctor.doctorAvatar
      }
    }
    //获取当类下的子分类的文章
    // let commonRes = await app.api.reqGeneralAllByCatalogue(14);//身体常识
    // if (commonRes.code === 200) {
    //   for (let item of commonRes.rows) {
    //     item.publishTime = renderTime(item.publishTime);
    //   }
    // }
    let commonRes1 = await app.api.reqCoreGeneralByPage(53,1,3);
    let commonRes2 = await app.api.reqCoreGeneralByPage(54,1,3);
    let commonRes3 = await app.api.reqCoreGeneralByPage(55,1,3);
    let commonList
    if (commonRes1.code === 200&&commonRes2.code===200&&commonRes3.code===200) {
      commonList=commonRes1.rows.concat(commonRes2.rows,commonRes3.rows)
      for (let item of commonList) {
        item.publishTime = renderTime(item.publishTime);
      }
    }
    let habitRes = await app.api.reqCoreGeneralByPage(15,1,5)//生活习惯
    if (habitRes.code === 200) {
      for (let item of habitRes.rows) {
        item.publishTime = renderTime(item.publishTime);
      }
    }
    let activityRes = await app.api.reqCoreGeneralByPage(16,1,5);//活动指南
    if (activityRes.code === 200) {
      for (let item of activityRes.rows) {
        item.publishTime = renderTime(item.publishTime);
      }
    }
    return {
      catagoryList:res.rows,
      doctorList:doctorRes.rows,
      // commonList:commonRes.rows,
      commonList,
      habitList:habitRes.rows,
      activityList:activityRes.rows,
    }
  },
};
</script>

<style scoped lang="less">
.el-row {
  margin-bottom: 20px;
  &:last-child {
    margin-bottom: 0;
  }
}
.grid-content {
  min-height: 36px;
}
.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}
.module-name {
  font-size: 20px;
  .icon-traditional {
    font-size: 24px;
    color: @themeColor;
  }
}
.modern-medical-img {
  width: 100%;
  height: 100%;
}
</style>

